//
//  AddWeatherCollectionViewCell.swift
//  MoodDiary
//
//  Created by MoodDiary on 2020/11/28.
//

import UIKit

class AddWeatherCollectionViewCell: UICollectionViewCell {

    @IBOutlet weak var bgView: UIView!
    @IBOutlet weak var imgV: UIImageView!
    @IBOutlet weak var label: UILabel!
    
    var shouldShow: Bool? {
        didSet {
            if shouldShow == true {
                isHidden = false
            } else {
                isHidden = true
            }
        }
    }
    
    
    var isSelectCell: Bool? {
        didSet {
            if isSelectCell == true {
                createShadow(hasShadow: false)
            } else {
                createShadow()
            }
        }
    }
    
    var showLabel: Bool? {
        didSet {
            if showLabel == true {
                label.isHidden = false
                imgV.isHidden = true
            } else {
                label.isHidden = true
                imgV.isHidden = false
            }
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        createShadow()
    }
    
    func createShadow(hasShadow: Bool = true) {
        bgView.layer.cornerRadius = 12.0
        
        guard hasShadow == true else {
            bgView.layer.shadowOpacity = 0
            bgView.layer.borderWidth = 1.0
            bgView.layer.borderColor = UIColor.hexColor(hex: "#F8AE00").cgColor
            return
        }
        
        bgView.layer.shadowOpacity = 1.0
        bgView.layer.shadowOffset = CGSize(width: 0, height: 0)
        bgView.layer.shadowRadius = 2.0
        bgView.layer.shadowColor = UIColor.init(white: 0.6, alpha: 0.4).cgColor
        bgView.layer.borderWidth = 0
        bgView.layer.borderColor = UIColor.clear.cgColor
    }

}
